home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.netobjects.nfx.ui.OrderedListModel;
- import asp.netobjects.nfx.util.ExceptionHandler;
- import asp.netobjects.nfx.util.ExternalError;
- import asp.netobjects.nfx.util.InternalError;
- import asp.netobjects.nfx.wizard.Wizard;
- import asp.netobjects.nfx.wizard.WizardPage;
- import asp.netobjects.nfx.wizard.WizardPageView;
- import asp.util.ResourceUtil;
- import asp.wizard.def.DefConnection;
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.ImageIcon;
- import com.sun.java.swing.table.DefaultTableModel;
- import com.sun.java.swing.table.TableModel;
- import java.util.Vector;
-
- public class WizardModelSubDbQuerySort extends WizardModelSub {
- private SubDBQueryData _Data;
- private WizardSubDbQuery _Wizard;
- // $FF: synthetic field
- static Class class$asp$wizard$WVPanelDbQuerySort;
-
- public WizardModelSubDbQuerySort() {
- super.dmCanFinish = true;
- super.dmIsLastPage = true;
- }
-
- public WizardModelSubDbQuerySort(Wizard wizard, String bullet, String info, ImageIcon icon, ExceptionHandler handler) {
- super(wizard, bullet, info, icon, handler);
- super.dmCanFinish = true;
- super.dmIsLastPage = true;
- this._Wizard = (WizardSubDbQuery)wizard;
- this._Data = this._Wizard.getData();
- }
-
- public void updateTableComboBox() {
- WizardViewSubDbQuerySort view = (WizardViewSubDbQuerySort)((WizardPage)this).getView();
- OrderedListModel tables = this._Data.getSelectedTables();
- view.setTableComboBoxModel(tables);
- }
-
- public void updateFieldList() {
- WizardViewSubDbQuerySort view = (WizardViewSubDbQuerySort)((WizardPage)this).getView();
- OrderedListModel olmFields = new OrderedListModel();
- String selTableName = view.getSelectedTable();
- if (selTableName != null && !selTableName.equals("")) {
- DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
- SubDBQueryData.setFields(dc, olmFields, selTableName, (boolean[])null);
- olmFields.setOrdered(true);
- }
-
- view.setFieldListModel(olmFields);
- }
-
- public void loadView() {
- this.updateTableComboBox();
- this.updateFieldList();
- this.loadValues();
- }
-
- public void loadValues() {
- this._Data.removeUnsupportedSorts();
- Vector sorts = this._Data.getSorts();
- WizardViewSubDbQuerySort view = (WizardViewSubDbQuerySort)((WizardPage)this).getView();
- DefaultTableModel tm = (DefaultTableModel)view.getSorts();
-
- while(tm.getRowCount() > 0) {
- tm.removeRow(0);
- }
-
- Vector dir = this.getDirections();
- Vector aRow = null;
-
- for(int i = 0; i < sorts.size(); ++i) {
- SubDBQueryData.SortOb sort = (SubDBQueryData.SortOb)sorts.elementAt(i);
- aRow = new Vector();
- aRow.addElement(sort.getTable() + "." + sort.getField());
- String asc;
- if (sort.isAscending()) {
- asc = dir.elementAt(0).toString();
- } else {
- asc = dir.elementAt(1).toString();
- }
-
- aRow.addElement(asc);
- tm.addRow(aRow);
- }
-
- }
-
- public void commit() throws InternalError, ExternalError {
- WizardViewSubDbQuerySort view = (WizardViewSubDbQuerySort)((WizardPage)this).getView();
- TableModel tm = view.getSorts();
- Vector dir = this.getDirections();
- this._Data.removeAllSorts();
-
- for(int i = 0; i < tm.getRowCount(); ++i) {
- String strTemp = tm.getValueAt(i, 0).toString();
- int nIndex = strTemp.indexOf(".");
- String strTable = strTemp.substring(0, nIndex);
- String strField = strTemp.substring(nIndex + 1);
- strTemp = tm.getValueAt(i, 1).toString();
- boolean bAscending = strTemp.compareTo(dir.elementAt(0).toString()) == 0;
- this._Data.addSort(strTable, strField, bAscending);
- }
-
- }
-
- public Vector getDirections() {
- String Options = ResourceUtil.getResourceString("asp.wizard.res", class$asp$wizard$WVPanelDbQuerySort != null ? class$asp$wizard$WVPanelDbQuerySort : (class$asp$wizard$WVPanelDbQuerySort = class$("asp.wizard.WVPanelDbQuerySort")), "option.headerdirection");
- return UiUtil.strToVector(Options);
- }
-
- public void validate() throws InternalError, ExternalError {
- super.validate();
- }
-
- protected WizardPageView getViewSingleInstance() {
- WizardViewSubDbQuerySort wizard = (WizardViewSubDbQuerySort)WizardViewSubDbQuerySort.getInstance();
- return WizardViewSubDbQuerySort.getInstance();
- }
-
- // $FF: synthetic method
- static Class class$(String class$) {
- try {
- return Class.forName(class$);
- } catch (ClassNotFoundException forName) {
- throw new NoClassDefFoundError(((Throwable)forName).getMessage());
- }
- }
- }
-